/*
 * @Author: your name
 * @Date: 2021-04-14 11:36:26
 * @LastEditTime: 2021-04-19 10:08:10
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /flutter_demo/lib/routes/Routes.dart
 */
import 'package:flutter/material.dart';
import 'package:flutter_demo/pages/AppBar.dart';
import 'package:flutter_demo/pages/Forms.dart';
import 'package:flutter_demo/pages/NewsContent.dart';
import 'package:flutter_demo/pages/Product.dart';
import 'package:flutter_demo/pages/ProductInfo.dart';
import 'package:flutter_demo/pages/RefreshData.dart';
import 'package:flutter_demo/pages/RenderData.dart';
import 'package:flutter_demo/pages/ScanQrcode.dart';
import 'package:flutter_demo/pages/Search.dart';
import 'package:flutter_demo/pages/StoragePage.dart';
import 'package:flutter_demo/pages/TabControl.dart';
import 'package:flutter_demo/pages/Tabs.dart';
import 'package:flutter_demo/pages/TakePhoto.dart';
import 'package:flutter_demo/pages/User.dart';
import 'package:flutter_demo/pages/VideoPage.dart';
import 'package:flutter_demo/pages/users/Login.dart';
import 'package:flutter_demo/pages/users/RegisterFirst.dart';
import 'package:flutter_demo/pages/users/RegisterSecond.dart';
import 'package:flutter_demo/pages/users/RegisterThrid.dart';

final routes = {
  '/': (context) => TabPage(),
  '/login': (context) => LoginPage(),
  '/registerFirst': (context) => RegisterFirstPage(),
  '/registerSecond': (context) => RegisterSecondPage(),
  '/registerThrid': (context) => RegisterThridPage(),
  '/form': (context) => FormsPage(),
  '/search': (context, {arguments}) => SearchPage(arguments: arguments),
  '/product': (context) => ProductPage(),
  '/productInfo': (context, {arguments}) =>
      ProductInfoPage(arguments: arguments),
  '/appBarDemo': (context) => AppBarDemo(),
  '/tabControl': (context) => TabControlPage(),
  '/user': (context) => UserPage(),
  '/renderData': (context) => RenderDataPage(),
  '/refreshData': (context) => RefreshDataPage(),
  '/newContents': (context, {arguments}) =>
      NewsContentPage(arguments: arguments),
  '/takePhoto': (context) => TakePhotoPage(),
  '/video': (context) => VideoPage(),
  '/storage': (context) => StoragePage(),
  '/scanQrcode': (context) => ScanQrcodePage()
};

var onGeneratePageRoute = (RouteSettings settings) {
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];

  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
